package com.shujia.connectionPool;

import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

public class ConnectionPoolConfig {
    String user;
    String passwd;
    String url;

    String driver;

    int initNum;
    int maxNum;


    public ConnectionPoolConfig() {
        Properties properties = new Properties();
        try {
            properties.load(new FileReader("redisCode/src/main/resources/connectionPool.properties"));
            user = properties.getProperty("user");
            passwd = properties.getProperty("passwd");
            url = properties.getProperty("url");
            driver = properties.getProperty("driver");
            initNum = Integer.parseInt(properties.getProperty("initNum"));
            maxNum = Integer.parseInt(properties.getProperty("maxNum"));

        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }

    public ConnectionPoolConfig(String user, String passwd, String url, String driver, int initNum, int maxNum) {
        this.user = user;
        this.passwd = passwd;
        this.url = url;
        this.driver = driver;
        this.initNum = initNum;
        this.maxNum = maxNum;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPasswd() {
        return passwd;
    }

    public void setPasswd(String passwd) {
        this.passwd = passwd;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getDriver() {
        return driver;
    }

    public void setDriver(String driver) {
        this.driver = driver;
    }

    public int getInitNum() {
        return initNum;
    }

    public void setInitNum(int initNum) {
        this.initNum = initNum;
    }

    public int getMaxNum() {
        return maxNum;
    }

    public void setMaxNum(int maxNum) {
        this.maxNum = maxNum;
    }

    @Override
    public String toString() {
        return "ConnectionPoolConfig{" +
                "user='" + user + '\'' +
                ", passwd='" + passwd + '\'' +
                ", url='" + url + '\'' +
                ", driver='" + driver + '\'' +
                ", initNum=" + initNum +
                ", maxNum=" + maxNum +
                '}';
    }


}
